﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xiaodingmarket_Domain.Interfaces;
using xiaodingmarket_Domain.Interfaces.IRepository;
using xiaodingmarket_Domain.Models;
using xiaodingmarket_Infra_Data.Context;

namespace xiaodingmarket_Infra_Data.Repository
{
    public class UserRepository : Repository<User>, IUserRepository
    {
        public UserRepository(MarketContext context)
            : base(context)
        {
            
        }
        public User Getuserrole(string id)
        {
            return DbSet.Include(c => c.userroles) //饥饿加载
                .Single(c => c.StudentId == id);
        }
        public User GetUserinfo(string id)
        {
            //return DbSet//饥饿加载
            //    .Single(c => c.StudentId == id);
            return DbSet.Include(c => c.userroles) //饥饿加载
                .Single(c => c.StudentId == id);
        }

        public bool hasCreate(string userid)
        {
            return DbSet.Any(o => o.Userid == userid);
        }
    }
}
